package com.lyfam.vaadin.view.form;

import java.util.Iterator;

import com.lyfam.annotation.listener.Listener;
import com.lyfam.vaadin.formfactory.DealFormFactory;
import com.lyfam.vaadin.service.FakeServices;
import com.vaadin.data.Container;
import com.vaadin.data.util.IndexedContainer;

public class DealProductValueChangedListener implements Listener<DealFormFactory>
{
    @Override
    public void process(DealFormFactory form, Object value)
    {
        Container c = form.getsubproduct().getContainerDataSource();
        c.removeAllItems();
        c = new IndexedContainer();
        for (final Iterator i = FakeServices.getSubProductList((String) value).iterator(); i.hasNext();)
        {
            c.addItem(i.next());
        }
        form.getsubproduct().setValue(null);
        form.getsubproduct().setContainerDataSource(c);
    }

}
